<?php

use yii\db\Migration;

class m180523_063112_alert_customer_field_config extends Migration
{
    /**
     * @inheritdoc
     */
    public function safeUp()
    {
        $this->addColumn('{{%customer_field_config}}','default_value',$this->string(10)->defaultValue('')->notNull()->comment('默认值'));
        $this->dropColumn('{{%customer_field_config}}', 'status');
        $this->addColumn('{{%customer_field_config_relation}}','status',$this->smallInteger(1)->defaultValue(1)->notNull()->comment('状态 1 启用 1禁用'));
    }

    public function safeDown()
    {
        $this->dropColumn('{{%customer_field_config}}', 'default_value');
        $this->dropColumn('{{%customer_field_config_relation}}', 'status');
        $this->dropColumn('{{%customer_field_config_relation}}', 'notes');
        $this->addColumn('{{%customer_field_config}}','status',$this->smallInteger(1)->defaultValue(1)->notNull()->comment('状态 1 启用 1禁用'));
        $this->addColumn('{{%customer_field_config}}','notes',$this->string(20)->defaultValue('')->notNull()->comment('字段注释'));

    }

    /*
    // Use up()/down() to run migration code without a transaction.
    public function up()
    {

    }

    public function down()
    {
        echo "m180523_063112_alert_customer_field_config cannot be reverted.\n";

        return false;
    }
    */
}
